import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('pipeControl')
export class pipeControl extends Component {

    @property(Prefab)
    pipePerfab:Prefab|null = null;
    @property(Node)
    canvas: Node = null;
    @property
    generateX:number = 10;
    top:number = 135.066;
    bottom:number = -12.419;
           // 方法2：生成整数随机数
           private getRandomIntHeight(): number {
            return Math.floor(Math.random() * (this.top - this.bottom + 1)) + this.bottom;
        }
    start() {
        this.schedule(()=>{
            let pipe = this.pipePerfab
            let pipeNode = instantiate(pipe)
            pipeNode.setParent(this.canvas);
            pipeNode.setPosition(this.generateX,this.getRandomIntHeight(),0)
            
        },4)
    }

    update(deltaTime: number) {
        
    }
}


